/*
 * Copyright (c) 2022.版权所有高金磊
 */

package 领扣算法.AA中等题.得到目标值的最少行动次数;

public class main {
    public int minMoves(int target, int maxDoubles) {
        //贪心算法
        int count=0;
        while (target!=1){

            if (maxDoubles<=0)
                return count+target-1;
            if(target%2==1) {
                target--;

            }
            else {
                target/=2;
                maxDoubles--;
            }
            count++;
        }
        return count;

    }
}
